package com.gxar.quick.ar.server.base.model.protocol.client.wechat_mp;

import java.util.List;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;

public class WechatMpClientProtocolAssertUtil {

    private WechatMpClientProtocolAssertUtil() {
        // Nothing
    }

    public static void assertProtocol(WechatMpClientArProtocol outputProtocol) {
        assertThat(outputProtocol, notNullValue());

        assertIdentifyModel(outputProtocol.getIdentifyModel());

        assertContentModels(outputProtocol.getContentModels());
    }

    public static void assertIdentifyModel(WechatMpClientArIdentifyModel identifyModel) {
        assertThat(identifyModel, notNullValue());
//        assertThat(identifyModel.getVersion(), notNullValue());
        assertThat(identifyModel.getWorkId(), notNullValue());
        assertThat(identifyModel.getLinkUrl(), notNullValue());
        assertThat(identifyModel.getWidth(), notNullValue());
        assertThat(identifyModel.getHeight(), notNullValue());
        assertThat(identifyModel.getShowIdentify(), notNullValue());
        assertThat(identifyModel.getScale(), notNullValue());
        assertThat(identifyModel.getPosition(), notNullValue());
        assertThat(identifyModel.getRotation(), notNullValue());
    }

    public static void assertBorderModel(WechatMpClientArItemBorderModel borderModel) {
        assertThat(borderModel, notNullValue());
    }

    public static void assertContentModels(List<WechatMpClientArContentModel> contents) {
        assertThat(contents, notNullValue());
        assertThat(contents.isEmpty(), equalTo(false));

        contents.forEach(contentItem -> {
            assertThat(contentItem.getId(), notNullValue());
            assertThat(contentItem.getWorkId(), notNullValue());
            assertThat(contentItem.getType(), notNullValue());
            assertThat(contentItem.getSubType(), notNullValue());

//            assertThat(contentItem.getLinkType(), notNullValue());

            assertThat(contentItem.getSrc(), notNullValue());
            assertThat(contentItem.getPosition(), notNullValue());
            assertThat(contentItem.getRotation(), notNullValue());
            assertThat(contentItem.getFillType(), notNullValue());
            assertThat(contentItem.getIsBorder(), notNullValue());
            assertThat(contentItem.getHasBorder(), notNullValue());
            assertThat(contentItem.getAlphaMode(), notNullValue());
            assertThat(contentItem.getEffect(), notNullValue());
            assertThat(contentItem.getHasQuaternion(), notNullValue());
            assertThat(contentItem.getQuaternion(), notNullValue());

            if (contentItem.getHasBorder()) {
                assertBorderModel(contentItem.getBorder());
            }
        });
    }
}
